home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
UTILITY
/
DO1002.ARJ
/
DATES.SCR
< prev
next >
Wrap
Text File
|
1991-12-31
|
5KB
|
157 lines
.pg wi full clr
/STOP End
/GOSUB DrawCalendar
.go 1 17
»%t«DO»#« has a set of functions to handle dates and times. These
functions allow you to do date and time math and display date and
time strings and the day of the week.
.go 1 25
»bo«Press any key to continue . . .»#«&
.wi 10 10 80 25 gr
:ShowClock
.go 1 1
/big {time}
/INKEY "" DateTime2
/GOTO ShowClock
:DateTime2
/GOSUB DrawCalendar
/CLOCK ON 12 19
.wi 32 10 80 25
»%t«DATE»#« Converts a date string to a number
of days
»%t«TIME»#« Converts a time string to a number
of seconds
»%t«DTST»#« Converts a number of days to a date
string
»%t«TMST»#« Converts a number of seconds
to a time string
»%t«DAY»#« Returns day of the week
.pg -25
/CLOCK OFF
.wi full clr cy
FUNCTION NAME»gray«: »%t« Date »cy«
~064date({DateString})
/cw
Date converts »cy«{DateString}»#« to a number of »wh«days since 1/1/1901»#«.
»cy«{DateString}»#« can be in any one of a number of formats:
»ye«MM/DD/YY»#« "12/01/91" or "3/5/91"
»ye«"Month Day, Year"»#« "September 6, 1991" or
"Dec 7, 1991" or
"Dec. 7, 1991"
»gr«NOTE»wh«:»#« if you use this extended
format you »re«MUST»#« enclose the
date in quote marks.
»ye«~123date~125»#« Special variable which returns today's
date.
.pg clr
Here are some examples. Press »bo«<enter>»#« to execute each line.
| Today is @date({date})
| The date is @date(12/01/91)
| The date is also @date("December 1, 1991")
/SET Default ""
:DateExample
/GETS Date Default " Enter a Date (»bo«<enter>»#« to stop):"
/IF %Date NE "" DateExample2
The date %Date converted to days is: @date(%date)
/GOTO DateExample
:DateExample2
.pg wi full clr cy
FUNCTION NAME»gray«: »%t« Time »cy«
~064time({TimeString})
/cw
Converts »cy«{TimeString}»#« into a number of »wh«seconds since
midnight»#«. »cy«{TimeString}»#« can use »ye«24-hour time»#« (military time)
or "»ye«a.m./p.m.»#«" notation. It is in the format:
»ma«
HH:MM[:SS] [a.m.|p.m.]
»#«
It can also interpret the special variable »gr«~123time~125»#« which
represents the current time on your computer.
.pg
Here are some examples. Press »bo«<enter>»#« to execute each.
| The current time {time} = @time({time}) minutes since midnight
| Time = @time(11:10)
| Time = @time(13:23:00)
| Time = @time('1:23 pm')
.pg wi full clr cy
FUNCTION NAME»gray«: »%t« DateString »cy«
~064dtst({Days})
/cw
Converts a number of »wh«days since January 1, 1901»#« into a date
string in the format "»ye«MM/DD/YY»#«". »%t«DateString»#« can also handle
»wh«math calculations»#«.
Here are some examples. Press »bo«<enter>»#« to execute each one.
|/SET Date @date({date})
| @dtst(%date) is %date days since 1/1/1901.
| Tomorrow is @dtst(@date({date})+1)
.pg wi full clr cy
FUNCTION NAME»gray«: »%t« TimeString »cy«
~064tmst({seconds})
/cw
Converts a number representing »wh«seconds since midnight»#« into a
time string in the format "»ye«HH:MM:SS»#«" (»cy«24-hour time»#«).
»%t«TimeString»#« can also handle »wh«math functions»#«.
Here are some examples. Press »bo«<enter>»#« to execute each one.
|/SET Time @time({time})
| It is now %time seconds since midnight or @tmst(%time)
|/SET Time @time('3:35 pm')
| 3:35 pm (%time seconds) + 60 minutes is @tmst(%time+(60*60))
Note that calculations have to be in »wh«SECONDS»#«.
.pg wi full clr cy
FUNCTION NAME»gray«: »%t« DayOfWeek »cy«
~064day({DateString})
/cw
Returns the three character day of the week for »cy«{DateString}»#«.
Here are some examples. Press »bo«<enter>»#« to execute each.
| Today ({date}) is »gr«@day({date})»#«
| Tomorrow is »gr«@day(@dtst(@date({date})+1))»#«
The other days are »gr«@day(@dtst(@date({date})+2))»#«
»gr«@day(@dtst(@date({date})+3))»#«
»gr«@day(@dtst(@date({date})+4))»#«
»gr«@day(@dtst(@date({date})+5))»#«
»gr«@day(@dtst(@date({date})+6))»#«
/GOTO End
:DrawCalendar
.wi full clr wh
┌───┬───┬───┬───┬───┬───┬───┐
│»ma«Sun»wh«│»ma«Mon»wh«│»ma«Tue»wh«│»ma«Wed»wh«│»ma«Thu»wh«│»ma«Fri»wh«│»ma«Sat»wh«│
╞═══╪═══╪═══╪═══╪═══╪═══╪═══╡»ye« ╥─┐ ╓─╖ ╓╥╖ ╥─╖ ╓─╖ ╖ ╖ ╥─┐ ╓╥╖ ╥ ╥╥╖ ╥─╖»wh«
│ │ 1│ 2│ 3│ 4│ 5│ 6│»ye« ║ │ ╟─╢ ║ ╟─ ╟─╢ ║\║ ║ │ ║ ║ ║║║ ╟─ »wh«
├───┼───┼───┼───┼───┼───┼───┤»ye« ╨─┘ ╙ ╙ ╙ ╨─╜ ╙ ╙ ╙ ╙ ╨─┘ ╙ ╨ ╙╙╙ ╨─╜»wh«
│ 7│ 8│ 9│ 10│ 11│ 12│ 13│»ye« ╥─╖ ╖ ╖ ╖ ╖ ╓─╖ ╓╥╖ ╥ ╓─╖ ╖ ╖ ╓─╖»wh«
├───┼───┼───┼───┼───┼───┼───┤»ye« ╟─ ║ ║ ║\║ ║ ║ ║ ║ ║ ║\║ ╙─╖»wh«
│ 14│ 15│ 16│ 17│ 18│ 19│ 20│»ye« ╙ ╙─╜ ╙ ╙ ╙─╜ ╙ ╨ ╙─╜ ╙ ╙ ╙─╜»wh«
├───┼───┼───┼───┼───┼───┼───┤
│ 21│ 22│ 23│ 24│ 25│ 26│ 27│
├───┼───┼───┼───┼───┼───┼───┤
│ 28│ 29│ 30│ 31│ │ │ │
└───┴───┴───┴───┴───┴───┴───┘»#«
/RETURN
:End
/CLOCK OFF
/ENDEXEC CLEAR